package com.wootion.cims.module.communityresidence.household.controller;

import com.wootion.cims.module.communityresidence.household.dto.PageQueryHouse;
import com.wootion.cims.module.communityresidence.household.excel.ExcelDto;
import com.wootion.cims.module.communityresidence.household.service.HouseholdService;
import com.wootion.cims.module.communityresidence.occupancy.dto.OccupancyDto;
import com.wootion.cims.module.systemsetting.dictionary.model.LogAnotion;
import com.wootion.cims.response.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @Author: LanQiang
 * @Date: 2022/12/23/8:40
 * @Description: 作用xxx
 */
@RestController
@Api(value = "户籍情况")
@RequiresAuthentication
@RequestMapping(path = {"/household"})
public class HouseholdController {
    
    @Resource
    private HouseholdService householdService;
    

    /**
     * 户籍情况列表
     * @param pageQueryHouse
     * @return
     */
    @PostMapping(path = {"/list"})
    @ApiOperation(value = "户籍情况-列表查询", httpMethod = "POST",notes = "不是jso格式,而是K-V结构,例如：condition:name page:2 limit:20")
    public ResponseResult list(@RequestBody PageQueryHouse pageQueryHouse){
        return householdService.list(pageQueryHouse);
    }
    /**
     * 根据房屋id,查询当前业主以及关联的所有户籍人员(包括户主自身)信息
     * @param id
     * @return
     */
    @GetMapping(path = {"/find"})
    @ApiOperation(value = "查询入住人员信息", httpMethod = "GET",notes = "personId=1")
    public ResponseResult find(@RequestParam("id") String id){
        return householdService.find(id);
    }

    /**
     * 修改户籍情况
     * @return
     */
    @PostMapping(path = {"/update/save"})
    @ApiOperation(value = "修改户籍情况", httpMethod = "POST",notes = "")
    public ResponseResult updateSave(@RequestBody OccupancyDto occupancyDto, HttpServletRequest request){
        return householdService.updateSave(occupancyDto,request);
    }


    /**
     * 导出户籍列表
     * @param excelDto
     * @return
     */
    @LogAnotion(type = "导出",value = "1",incident = "户籍信息",prefixContent = "")
    @PostMapping(path = {"/excel"})
    @ApiOperation(value = "户籍情况-导出户籍列表", httpMethod = "POST",notes = "{\"ids\":[\"002443e3023366e6d984284134c63525\",\"09dbd05b9356f3cafae3d3bd7ced4b61\"]}")
    public ResponseResult houseExcel(@RequestBody ExcelDto excelDto){
        return householdService.houseExcel(excelDto);
    }
}
